package com.bwie.system.controller;

import com.bwie.common.pojo.res.LoginRes;
import com.bwie.common.result.Result;
import com.bwie.system.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RequiredArgsConstructor
@RestController
public class UserController {
    private final UserService userService;

    /**
     * 根据用户名查询用户信息
     * @param userName
     * @return
     */
    @GetMapping("/getUserByUserName/{userName}")
    public Result<LoginRes> getUserByUserName(@PathVariable("userName") String userName){
        LoginRes loginRes = userService.getUserByUserName(userName);
        return Result.success(loginRes);
    }

    /**
     * 根据手机号查询用户信息
     * @param phone
     * @return
     */
    @GetMapping("/getUserByPhone/{phone}")
    public Result<LoginRes> getUserByPhone(@PathVariable("phone") String phone){
        LoginRes loginRes = userService.getUserByPhone(phone);
        return Result.success(loginRes);
    }
}
